import processing.core.*; import java.applet.*; import java.awt.*; import java.awt.image.*; import java.awt.event.*; import java.io.*; import java.net.*; import java.text.*; import java.util.*; import java.util.zip.*; public class img2tile extends PApplet {
int COLS = 20;
int ROWS = 2;

PImage img;

public void setup(){
  img = loadImage("automat.png");

  int length = COLS * ROWS * 16;

  print("byte line["+length+"] = {");
  for(int r = 0; r<ROWS; r++){
    for(int c = 0; c<COLS; c++){

      for(int ir=0; ir<8; ir++){
        int bp1 = 0;
        int bp2 = 0;


        for(int ic=0; ic<8; ic++){
          int p = img.get(c*8+ic, r*8+ir);
          if(red(p) > 128) {
            bp1 += 1 << (7-ic);
          }
          bp2 = bp1;
        } 
        print(bp1+","+bp2+",");
      }
    } 
  }
  println("}");
}


  static public void main(String args[]) {     PApplet.main(new String[] { "img2tile" });  }}